package com.qykj.ddhing.pda.demo.arms.test1;

import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import com.jess.arms.base.BaseActivity;
import com.jess.arms.di.component.AppComponent;
import com.jess.arms.widget.autolayout.AutoToolbar;
import com.qykj.ddhing.pda.R;
import com.zhy.autolayout.AutoRelativeLayout;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * author : 0000
 * desc   :
 * time   : 2018/07/19
 * updateTime : 2018/07/19
 */

public class LoginActivity extends BaseActivity<LoginPresenter> implements UserContract.View {
    @BindView(R.id.toolbar_back)
    AutoRelativeLayout toolbarBack;
    @BindView(R.id.toolbar_title)
    TextView toolbarTitle;
    @BindView(R.id.toolbar)
    AutoToolbar toolbar;
    @BindView(R.id.edtName)
    EditText edtName;
    @BindView(R.id.edtPsw)
    EditText edtPsw;
    @BindView(R.id.btn)
    Button btn;

    @Override
    public void setupActivityComponent(@NonNull AppComponent appComponent) {
        DaggerUserComponent.builder()
                .appComponent(appComponent)
                .userModule(new UserModule(this))
                .build()
                .inject(this);
    }

    @Override
    public int initView(@Nullable Bundle savedInstanceState) {
        return R.layout.demo_activity_login;
    }

    @Override
    public void initData(@Nullable Bundle savedInstanceState) {

    }


    @Override
    public void showMessage(@NonNull String message) {

    }

    @Override
    public boolean useEventBus() {
        return false;
    }

    @Override
    public boolean useFragment() {
        return false;
    }

    @Override
    public void updateUI(User data) {
        if(data!=null){
            btn.setText(data.getCode()+""+data.isSuccess());
        }
    }

    @OnClick(R.id.btn)
    public void onViewClicked() {
        mPresenter.requestUsers(false);
    }

    @Override
    public User getUIdataUserInfo() {
        User user=new User();
        user.setName(edtName.getText().toString());
        user.setPws(edtPsw.getText().toString());
        return user;
    }
}
